package com.javasm.controller.goods;


import com.javasm.common.http.AxiosResult;
import com.javasm.common.valid.addGroup;
import com.javasm.controller.base.BaseController;
import com.javasm.domin.entity.goods.GoodsAdjust;
import com.javasm.domin.entity.goods.GoodsAdjustInfo;
import com.javasm.service.goods.IGoodsAdjustInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author whl
 * @since 2022-01-16
 */
@RestController
@RequestMapping("goods-adjust-info")
@RequiredArgsConstructor
public class GoodsAdjustInfoController extends BaseController {

    private  final IGoodsAdjustInfoService iGoodsAdjustInfoService;
    /**
     * 添加
     */
    @PostMapping
    public AxiosResult<Void> add(@Validated(addGroup.class) @RequestBody GoodsAdjustInfo goodsAdjustInfo) {

        return toAxios(iGoodsAdjustInfoService.save(goodsAdjustInfo));
    }


    /**
     * 根据id查询
     */
    @GetMapping("{id}")
    public AxiosResult<GoodsAdjustInfo> findById(@PathVariable Long id) {
        GoodsAdjustInfo byId = iGoodsAdjustInfoService.getById(id);

        return AxiosResult.success(byId);
    }

}
